[HorizonDB] Add restore command#10049
Draft
alxhghs wants to merge 9 commits into
Draft
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The `az horizondb restore` command sent createMode=PointInTimeRestore and sourceClusterResourceId but omitted pointInTimeUTC, which the service requires (MissingRequiredParameter). Add a `--restore-time` argument (optional, defaults to current UTC time, parse-validated) mirroring `az postgres flexible-server restore`, and pass it as point_in_time_utc. - _params.py: add --restore-time arg with current-time default. - custom_commands.py: parse --restore-time and set point_in_time_utc. - _help.py: add point-in-time restore example. - test: supply a valid restore time (utcnow - 6 min, clearing the 300s preview buffer) and assert createMode; re-record live cassette and commit test log. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| horizondb restore | cmd horizondb restore added |
Collaborator
|
HorizonDB |
…izondb-restore-operations # Conflicts: # src/horizondb/HISTORY.rst # src/horizondb/azext_horizondb/_params.py
Pan-Qi
requested changes
Jul 7, 2026
Pan-Qi
left a comment
Contributor
There was a problem hiding this comment.
- please resolve the conflict
- please mark as open if this PR is ready for review
nachoalonsoportillo
suggested changes
Jul 10, 2026
|
Thanks @nachoalonsoportillo for making these changes. |
- Clarify restore help/summary wording and examples - Reword source-cluster arg and error message (resource identifier) - Default restore-time to 6 minutes before now during preview when omitted - Update example timestamps Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…izondb-restore-operations # Conflicts: # src/horizondb/HISTORY.rst # src/horizondb/azext_horizondb/commands/custom_commands.py # src/horizondb/azext_horizondb/tests/latest/recordings/test_horizondb_cluster_mgmt.yaml
alxhghs
marked this pull request as ready for review
July 14, 2026 20:01
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
Hi @Pan-Qi, I resolved the merge conflict and published the PR |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new az horizondb restore command to create a HorizonDB cluster via point-in-time restore from an existing source cluster, and updates the extension’s docs/tests/versioning to reflect the new capability.
Changes:
- Introduces
horizondb restorecommand wiring plus implementation that setscreateMode=PointInTimeRestoreand sends the restore point timestamp. - Adds new CLI parameters/help for
--source-clusterand--restore-time, plus scenario test coverage for restore. - Bumps extension version and documents the change in HISTORY/README.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/horizondb/setup.py | Bumps extension version. |
| src/horizondb/README.md | Documents the new restore command in the feature list. |
| src/horizondb/HISTORY.rst | Adds release notes entry for restore support. |
| src/horizondb/azext_horizondb/tests/latest/test_horizondb_commands.py | Extends scenario test to perform a restore and cleanup. |
| src/horizondb/azext_horizondb/commands/custom_commands.py | Implements restore logic (source cluster resolution + restore-time parsing). |
| src/horizondb/azext_horizondb/cluster_commands.py | Registers horizondb restore in the command table. |
| src/horizondb/azext_horizondb/_params.py | Adds --source-cluster and --restore-time arguments. |
| src/horizondb/azext_horizondb/_help.py | Adds help + examples for horizondb restore. |
Comment on lines
+104
to
+116
| def _parse_restore_time(restore_time): | ||
| import datetime | ||
| if restore_time is None: | ||
| # During preview, default to 6 minutes before now to satisfy the minimum 5-minute buffer. | ||
| return datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0) - datetime.timedelta(minutes=6) | ||
| from dateutil import parser | ||
| try: | ||
| return parser.parse(restore_time) | ||
| except (ValueError, OverflowError): | ||
| raise InvalidArgumentValueError( | ||
| "The restore time value has an incorrect date format. " | ||
| "Please use ISO8601 format, e.g., 2026-07-15T02:10:00+00:00.") | ||
|
|
Comment on lines
+106
to
+108
| if restore_time is None: | ||
| # During preview, default to 6 minutes before now to satisfy the minimum 5-minute buffer. | ||
| return datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0) - datetime.timedelta(minutes=6) |
Comment on lines
+75
to
+93
| if self.is_live: | ||
| from datetime import datetime, timedelta, timezone | ||
|
|
||
| restored_cluster_name = self.create_random_name(CLUSTER_NAME_PREFIX, CLUSTER_NAME_MAX_LENGTH) | ||
|
|
||
| # Restore time must be at least 5 minutes (300s) before the current time during preview. | ||
| restore_time = (datetime.now(timezone.utc) - timedelta(minutes=6)).replace(microsecond=0).isoformat() | ||
|
|
||
| # Restore cluster | ||
| restore_result = self.cmd('horizondb restore -g {} -n {} --source-cluster {} --restore-time {}'.format( | ||
| resource_group, restored_cluster_name, cluster_name, restore_time)).get_output_in_json() | ||
|
|
||
| self.assertEqual(restore_result['name'], restored_cluster_name) | ||
| self.assertEqual(restore_result['properties']['createMode'], 'PointInTimeRestore') | ||
|
|
||
| # Delete restored cluster | ||
| self.cmd('horizondb delete -g {} -n {} --yes'.format(resource_group, restored_cluster_name), | ||
| checks=NoneCheck()) | ||
|
|
Contributor
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Contributor
|
@alxhghs kindly ping for resolving the failed tests |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ight # Conflicts: # src/horizondb/HISTORY.rst
alxhghs
marked this pull request as draft
July 23, 2026 16:49
- Normalize --restore-time to a UTC-aware datetime in _parse_restore_time: a value without an explicit offset is interpreted as UTC and an offset-aware value is converted to UTC, so the service never receives a naive/ambiguous datetime. - Run the restore scenario in playback (not just live) so `az horizondb restore` is actually exercised by the recorded cassette. Playback matches on method + URI only, so the computed restore-time is not replay-sensitive. - Add unit tests for _parse_restore_time (default, naive, offset-aware, Z suffix, invalid). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9af6f71f-2404-4076-ba3f-b6730e166e91
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
az horizondb restoreto create a new HorizonDB cluster as a point-in-time restore of an existing source cluster.restore— restore a HorizonDB cluster from a source cluster. Accepts--source-clusterand an optional--restore-time(RFC3339). When--restore-timeis omitted it defaults to the current UTC time. The command sendscreateMode=PointInTimeRestorewith the requiredPointInTimeUTC.Mirrors the
az postgres flexible-server restoreconvention (--restore-time, optional, default = now, parsed/validated withdateutil).Bumps the extension version to
1.0.086and documents the change in HISTORY.rst / README.md.Testing
azdev style horizondb— PASSEDazdev linter horizondb— PASSEDHorizonDBClusterMgmtScenarioTestrecorded live (create → show → list → update → restore → delete) and verified in playback — PASSEDHistory Notes
az horizondb restore.🤖 PR Validation —⚠️ Review suggested